<template>
  <view class="audio-record-container">
    <!-- 状态栏占位 -->
    <view class="status-bar" :style="{height: statusBarHeight + 'px'}"></view>
    
    <!-- 顶部导航栏 -->
    <view class="audio-navbar">
      <view class="navbar-content">
        <view class="nav-left" @click="goBack">
          <text class="back-icon">‹</text>
        </view>
        <text class="nav-title">测量内痿声音</text>
        <view class="nav-right">
          <view class="nav-action-btn">
            <text class="action-dots">⋯</text>
          </view>
          <view class="nav-action-btn">
            <text class="action-location">📍</text>
          </view>
        </view>
      </view>
    </view>

    <!-- 内容区域 -->
    <view class="content-area">
      <!-- 声音录制卡片 -->
      <view class="audio-card">
        <!-- 声音标题 -->
        <view class="audio-title">声音</view>
        
        <!-- 声音波形显示 -->
        <view class="waveform-container">
          <view class="waveform">
            <view class="wave-bar" v-for="(height, index) in waveHeights" :key="index" :style="{height: height + 'rpx'}"></view>
          </view>
        </view>
        
        <!-- 底部信息行：时间 + 播放控制 -->
        <view class="bottom-info">
          <view class="time-info">
            <text class="recording-date">2025/05/20 17:45</text>
            <text class="recording-duration">10s</text>
          </view>
          <view class="play-control">
            <text class="duration-text">10s</text>
            <view class="play-btn" @click="togglePlay">
              <text class="play-icon">▶</text>
            </view>
          </view>
        </view>
      </view>
      
      <!-- 蓝牙连接状态 -->
      <view class="bluetooth-section">
        <view class="bluetooth-icon">
          <text class="bt-icon">🔵</text>
        </view>
        <text class="bluetooth-status">蓝牙已连接</text>
      </view>
      
      <!-- 操作按钮区域 -->
      <view class="action-buttons">
        <view class="primary-btn" @click="startRecord">
          <text class="btn-text">开始/完成测量</text>
        </view>
        <view class="secondary-buttons">
          <view class="secondary-btn" @click="bindDevice">
            <text class="btn-text">绑定设备</text>
          </view>
          <view class="secondary-btn" @click="myDevice">
            <text class="btn-text">我的设备</text>
          </view>
        </view>
      </view>
    </view>
  </view>
</template>

<script>
export default {
  data() {
    return {
      statusBarHeight: 0,
      isPlaying: false,
      playProgress: 30,
      waveHeights: [20, 40, 60, 30, 80, 45, 35, 70, 25, 55, 40, 90, 20, 65, 30, 50, 75, 35, 60, 25]
    }
  },
  
  onLoad() {
    this.getSystemInfo()
  },
  
  methods: {
    getSystemInfo() {
      const systemInfo = uni.getSystemInfoSync()
      this.statusBarHeight = systemInfo.statusBarHeight || 0
    },
    
    goBack() {
      uni.navigateBack()
    },
    
    togglePlay() {
      this.isPlaying = !this.isPlaying
      // 这里可以添加播放/暂停逻辑
    },
    
    startRecord() {
      uni.showToast({
        title: '开始测量',
        icon: 'success'
      })
    },
    
    bindDevice() {
      uni.navigateTo({
        url: '/pages/bindDevice/index'
      })
    },
    
    myDevice() {
      uni.navigateTo({
        url: '/pages/myDevice/index'
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.audio-record-container {
  min-height: 100vh;
  background: #F5F5F5;
  position: relative;
}

.status-bar {
  background: #FFFFFF;
}

.audio-navbar {
  background: #FFFFFF;
  height: 88rpx;
  border-bottom: 1px solid #E5E5E5;
  
  .navbar-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 100%;
    padding: 0 32rpx;
    
    .nav-left {
      width: 60rpx;
      height: 60rpx;
      display: flex;
      align-items: center;
      justify-content: center;
      
      .back-icon {
        font-size: 48rpx;
        color: #333333;
        font-weight: bold;
      }
    }
    
    .nav-title {
      font-size: 36rpx;
      font-weight: bold;
      color: #333333;
    }
    
    .nav-right {
      display: flex;
      align-items: center;
      
      .nav-action-btn {
        width: 60rpx;
        height: 60rpx;
        background: rgba(0, 0, 0, 0.05);
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        margin-left: 16rpx;
        
        .action-dots, .action-location {
          font-size: 24rpx;
          color: #666666;
        }
      }
    }
  }
}

.content-area {
  padding: 60rpx 32rpx;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.audio-card {
  width: 100%;
  background: #FFFFFF;
  border-radius: 24rpx;
  padding: 40rpx 32rpx;
  margin-bottom: 80rpx;
  box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.08);
  
  .audio-title {
    font-size: 48rpx;
    font-weight: bold;
    color: #333333;
    text-align: center;
    margin-bottom: 60rpx;
  }
  
  .waveform-container {
    margin-bottom: 40rpx;
    
    .waveform {
      display: flex;
      align-items: flex-end;
      justify-content: center;
      height: 200rpx;
      gap: 8rpx;
      
      .wave-bar {
        width: 8rpx;
        background: #333333;
        border-radius: 4rpx;
        min-height: 20rpx;
      }
    }
  }
  
  .bottom-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    
    .time-info {
      display: flex;
      gap: 40rpx;
      
      .recording-date, .recording-duration {
        font-size: 28rpx;
        color: #666666;
      }
    }
    
    .play-control {
      display: flex;
      align-items: center;
      gap: 16rpx;
      
      .duration-text {
        font-size: 28rpx;
        color: #666666;
      }
      
      .play-btn {
        width: 80rpx;
        height: 80rpx;
        background: #2196F3;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        
        .play-icon {
          color: #FFFFFF;
          font-size: 32rpx;
          margin-left: 4rpx;
        }
      }
    }
  }
}

.bluetooth-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 80rpx;
  
  .bluetooth-icon {
    width: 120rpx;
    height: 120rpx;
    background: #2196F3;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 24rpx;
    
    .bt-icon {
      font-size: 48rpx;
      color: #FFFFFF;
    }
  }
  
  .bluetooth-status {
    font-size: 32rpx;
    color: #333333;
    font-weight: 500;
  }
}

.action-buttons {
  width: 100%;
  
  .primary-btn {
    width: 100%;
    height: 96rpx;
    background: #2196F3;
    border-radius: 48rpx;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 32rpx;
    
    .btn-text {
      font-size: 32rpx;
      color: #FFFFFF;
      font-weight: 500;
    }
  }
  
  .secondary-buttons {
    display: flex;
    gap: 32rpx;
    
    .secondary-btn {
      flex: 1;
      height: 80rpx;
      background: #FFFFFF;
      border: 2rpx solid #2196F3;
      border-radius: 40rpx;
      display: flex;
      align-items: center;
      justify-content: center;
      
      .btn-text {
        font-size: 28rpx;
        color: #2196F3;
        font-weight: 500;
      }
    }
  }
}
</style> 